#include <iostream>
#include "pcl/point_cloud.h"
#include "pcl/pcl_base.h"
#include "pcl/io/pcd_io.h"
#include "pcl/io/ply_io.h"

/**
 * pcd 转 ply 文件
 * @param argc
 * @param argv[1] 待转换的 pcd 文件
 * @param argv[2] 转换后的 ply 文件
 * @return
 */
int main(int argc, char** argv) {
    if (argc != 3) {
        std::cout << "Correct command is: pcd2ply <pcd_file> <ply_file>" << std::endl;
        return 0;
    }
    pcl::PCLPointCloud2 pclPointCloud2{};
    pcl::io::loadPCDFile(argv[1], pclPointCloud2);

    pcl::PLYWriter plyWriter{};

    plyWriter.write(argv[2], pclPointCloud2, Eigen::Vector4f::Zero(), Eigen::Quaternionf::Identity(), true, true);
    return 0;
}